package com.ssy.lingxi.message.repository;


import com.ssy.lingxi.message.entity.MemberMessage;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 会员消息仓库类
 * @author yzc
 * @version 2.0.0
 * @date 2020/10/27
 */
@Repository
public interface MemberMessageRepository extends JpaRepository<MemberMessage, Long> , JpaSpecificationExecutor<MemberMessage> {

    Page<MemberMessage> findAllByRecMemberIdAndRecRoleId(Long recMemberId, Long recRoleId, Pageable page);

    List<MemberMessage> findAllByRecMemberIdAndRecRoleIdAndStatus(Long recMemberId, Long recRoleId, Integer status);

    List<MemberMessage> findAllByRecMemberIdAndRecRoleIdAndMainMessageIdIn(Long recMemberId, Long recRoleId, List<Long> messageIds);

    long countByRecMemberIdAndRecRoleIdAndRecUserIdAndStatus(Long memberId, Long memberRoleId, Long userId, Integer status);

    List<MemberMessage> findByIdIn(List<Long> ids);

    boolean existsBySendMemberIdAndSendRoleIdAndRecMemberIdAndRecRoleIdAndBusinessType(Long sendMemberId, Long sendRoleId, Long RecMemberId, Long recRoleId, String businessType);
}
